<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Suspend - Syntax &amp; Usage | AutoHotkey</title>
<meta name="description" content="The Suspend command disables or enables all or selected hotkeys and hotstrings." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>Suspend</h1>

<p>Disables or enables all or selected <a href="../Hotkeys.htm">hotkeys</a> and <a href="../Hotstrings.htm">hotstrings</a>.</p>

<pre class="Syntax"><span class="func">Suspend</span> <span class="optional">, Mode</span></pre>
<h2>Parameters</h2>
<dl>

  <dt>Mode</dt>
  <dd><p><strong>On</strong>: Suspends all <a href="../Hotkeys.htm">hotkeys</a> and <a href="../Hotstrings.htm">hotstrings</a> except those explained the Remarks section.</p>
      <p><strong>Off</strong>: Re-enables the hotkeys and hotstrings that were disable above.</p>
      <p><strong>Toggle</strong> (default): Changes to the opposite of its previous state (On or Off).</p>
    <p><strong>Permit</strong>: Does nothing except mark the current subroutine as being exempt from suspension.</p>
      <p><span class="ver">[v1.1.30+]:</span> The decimal values 1, 0 and -1 may be used in place of On, Off and Toggle, respectively.</p>
      </dd>

</dl>

<h2>Remarks</h2>
<p>By default, the script can also be suspended via its <a href="../Program.htm#tray-icon">tray icon</a> or <a href="../Program.htm#main-window">main window</a>.</p>
<p>Any hotkey/hotstring subroutine whose very first line is Suspend (except <code>Suspend On</code>) will be exempt from suspension. In other words, the hotkey will remain enabled even while suspension is ON. This allows  suspension to be turned off via such a hotkey.</p>
<p>The <a href="_InstallKeybdHook.htm">keyboard</a> and/or <a href="_InstallMouseHook.htm">mouse</a> hooks will be installed or removed if justified by the changes made by this command.</p>
<p>To disable selected hotkeys or hotstrings automatically based on the type of window that is present, use <a href="_IfWinActive.htm">#IfWinActive/Exist</a>.</p>
<p>Suspending a script's hotkeys does not stop the script's already-running <a href="../misc/Threads.htm">threads</a> (if any); use <a href="Pause.htm">Pause</a> to do that.</p>
<p>When a script's hotkeys are suspended, its tray icon changes to the letter S. This can be avoided by freezing the icon, which is done by specifying 1 for the last parameter of the Menu command. For example:</p>
<pre><a href="Menu.htm">Menu</a>, Tray, Icon, C:\My Icon.ico, , 1</pre>
<p>The built-in variable A_IsSuspended contains 1 if the script is suspended and 0 otherwise.</p>
<h2>Related</h2>
<p><a href="_IfWinActive.htm">#IfWinActive/Exist</a>, <a href="Pause.htm">Pause</a>, <a href="Menu.htm">Menu</a>, <a href="ExitApp.htm">ExitApp</a></p>
<h2>Examples</h2>
<div class="ex" id="ExHotkey">
<p><a href="#ExHotkey">#1</a></p>
<pre>^!s::Suspend  <em>; Assign the toggle-suspend function to a hotkey.</em></pre>
</div>

<div class="ex" id="PostMessage">
<p><a href="#PostMessage">#2</a>: Send a Suspend command to another script.</p>
<pre><a href="DetectHiddenWindows.htm">DetectHiddenWindows</a>, On
WM_COMMAND := 0x111
ID_FILE_SUSPEND := 65404
<a href="PostMessage.htm">PostMessage</a>, WM_COMMAND, ID_FILE_SUSPEND,,, C:\YourScript.ahk ahk_class AutoHotkey</pre>
</div>

</body>
</html>
